﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Stock_App_V1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
                DragMove();
        }

        private void clearBtn_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 沪深A
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SSEx_Btn_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new StockPage());
            ResetExpandIcons("SSEx_BtnExpandIcon");
        }
        /// <summary>
        /// 消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Msg_Btn_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new MessagePage());
            ResetExpandIcons("Msg_BtnExpandIcon");
        }
        /// <summary>
        /// 记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Note_Btn_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new RecordPage());
            ResetExpandIcons("Note_BtnExpandIcon");
        }
        /// <summary>
        /// 监控
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Control_Btn_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new MonitorPage());
            ResetExpandIcons("Control_BtnExpandIcon");
        }
        private void ResetExpandIcons(string activeIconName)
        {
            // 重置所有菜单按钮的展开图标的可见性和样式
            SSEx_BtnExpandIcon.Visibility = activeIconName == "SSEx_BtnExpandIcon" ? Visibility.Visible : Visibility.Hidden;
            SSEx_Btn.Style = activeIconName == "SSEx_BtnExpandIcon" ? (Style)FindResource("activeMenuButton") : (Style)FindResource("menuButton");

            Msg_BtnExpandIcon.Visibility = activeIconName == "Msg_BtnExpandIcon" ? Visibility.Visible : Visibility.Hidden;
            Msg_Btn.Style = activeIconName == "Msg_BtnExpandIcon" ? (Style)FindResource("activeMenuButton") : (Style)FindResource("menuButton");

            Note_BtnExpandIcon.Visibility = activeIconName == "Note_BtnExpandIcon" ? Visibility.Visible : Visibility.Hidden;
            Note_Btn.Style = activeIconName == "Note_BtnExpandIcon" ? (Style)FindResource("activeMenuButton") : (Style)FindResource("menuButton");

            Control_BtnExpandIcon.Visibility = activeIconName == "Control_BtnExpandIcon" ? Visibility.Visible : Visibility.Hidden;
            Control_Btn.Style = activeIconName == "Control_BtnExpandIcon" ? (Style)FindResource("activeMenuButton") : (Style)FindResource("menuButton");

        }
    }
}
